package emulator.shell.GUI;

import javax.swing.text.BadLocationException;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyledDocument;


public class ConsoleWriteEvent implements Runnable {
	private ConsoleFrame console = null;
	private String text;
	private SimpleAttributeSet attributes;
	
	ConsoleWriteEvent(ConsoleFrame console, String text, SimpleAttributeSet attributes) {
		this.console = console;
		this.text = text;
		this.attributes = attributes;
	}
	@Override
	public void run() {
		if (console.getContentFrame() != null)
		{
		    try {
			    StyledDocument doc = console.getContentFrame().getStyledDocument();
			    doc.insertString( doc.getLength(), text, attributes );
		    } catch( BadLocationException ex ) {
		    }
		}
	}

}
